#!/bin/bash -e

function info() {
echo Usage: `basename $0` '[-i interval] in.bam'
exit 2
}

while getopts  ":p:f:i:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
        i) interval=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

# echo;echo $java_run/gatk CountIntervals
# $java_run/gatk \
# -R $ref_genome \
# -T CountIntervals \
# -o output.txt
# -check $interval

:<<callable_info
This tool considers the coverage at each locus and emits either a per base state or a summary interval BED file that partitions the genomic intervals into the following callable states:

REF_N
The reference base was an N, which is not considered callable the GATK
PASS
The base satisfied the min. depth for calling but had less than maxDepth to avoid having EXCESSIVE_COVERAGE
NO_COVERAGE
Absolutely no reads were seen at this locus, regardless of the filtering parameters
LOW_COVERAGE
There were fewer than min. depth bases at the locus, after applying filters
EXCESSIVE_COVERAGE
More than -maxDepth read at the locus, indicating some sort of mapping problem
POOR_MAPPING_QUALITY
More than --maxFractionOfReadsWithLowMAPQ at the locus, indicating a poor mapping quality of the reads
callable_info

echo;echo $java_run/gatk CallableLoci
$java_run/gatk \
-R $ref_genome \
-T CallableLoci \
-I $1 \
-summary $out_prefix.callable_summary.txt \
-o $out_prefix.callable_status.bed \
-L $interval

:<<old
echo;echo $java_run/gatk CountLoci
$java_run/gatk \
-R $ref_genome \
-T CountLoci \
-I $1 \
-o $out_prefix.loci_callable.txt \
-L $interval

echo;echo $java_run/gatk FindCoveredIntervals
$java_run/gatk \
-R $ref_genome \
-T FindCoveredIntervals \
-I $1 \
-cov 6 \
--minBaseQuality 20 \
--minMappingQuality 20 \
-o $out_prefix.coverd_interval.txt \
-L $interval

echo;echo $java_run/gatk CountRODs
$java_run/gatk \
-R $ref_genome \
-T CountRODs \
-o $out_prefix.rod.txt \
--rod $2 \
-L $interval



:<<ase
echo;echo $java_run/gatk ASEReadCounter
$java_run/gatk \
-R $ref_genome \
-T ASEReadCounter \
-o $out_prefix.csv \
-I $1 \
-sites sites.vcf \
-U ALLOW_N_CIGAR_READS \
-minDepth 10 \
--minMappingQuality 10 \
--minBaseQuality 2 \
-drf DuplicateRead
ase

old



. $cmd_done